
package puyu.manage.service.template.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import puyu.manage.service.template.service.ITemplateService;
import puyu.manage.service.utils.except.AppException;
import puyu.manage.service.utils.R;
import puyu.manage.service.utils.ResponseMsg;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;
import java.util.Map;

/**
 *  @ClassName: 模版方法
 *  @author: whl
 *  @Date: 2024/5/27 14:33
 *  @Description: Description of this class
 */

@Slf4j
@RestController
@EnableSwagger2
@RequestMapping({"/template"})
@Api(tags = "模版类")
public class TemplateController {

    @Autowired
    private ITemplateService templateService;

    @ApiOperation(value = "执行扩展功能")
    @PostMapping(value = "/excuteFunc", produces = { "application/json; charset=UTF-8" })
    public ResponseMsg excuteFunc(@ApiParam(name="params",
            value="datas-数据",required=true) @RequestParam Map params
    ) throws Exception {
        ResponseMsg msg = null;
        List result = templateService.excuteFunc(params);
        msg = new ResponseMsg(result);
        return msg;
    }

    /**
     *
     * @param params
     * @param tokenid
     * @return
     * @throws AppException
     */
    @PostMapping("/updateagencyGuid")
    @ApiOperation(value = "启用-处室信息更新")
    public R updateagencyGuid(@RequestParam Map<String,Object> params, @RequestParam(value = "tokenid", required = true) String tokenid) throws Exception {

        return templateService.updateagencyGuid(params);
    }

    @GetMapping(value = "/restapi/v1/ca/organization/year/all", produces = { "application/json; charset=UTF-8" })
    public ResponseMsg   organization() throws Exception {
        ResponseMsg msg = null;
        List result = templateService.organization();
        msg = new ResponseMsg(result);
        return msg;
    }


    @GetMapping("ceshi")
    @ApiOperation(value = "测试接口")
    public R ceshi() {
        templateService.ceshi();
        return R.success("测试1121");
    }
}
